package 类与对象.包装类;

public class 包装类与String转换 {
    public static void main(String[] args) {
        Integer n1 = 128;//自动装箱

        //包装类转String
        String str1 = n1 + "";
        System.out.println(str1);

        System.out.println(n1.toString());

        String s = String.valueOf(n1);

        //String装包装类
        String n4 = "123456";
        Integer n3 = Integer.parseInt(n4);

        //因为new出来的，地址不一样
        Integer integer = new Integer(1);
        Integer integer1 = new Integer(1);
        System.out.println(integer == integer1);

        //如果在 -128 ~ 127 直接返回,否则就 new Integer()
        Integer i = 1;
        Integer j = 1;
        System.out.println(i == j);

        Integer a = 128;
        Integer b = 128;
        System.out.println(a == b);

        //只要有基本数据类型，==：表示比较的数值是否相等
        //应用数据类型，==：表示比较的是地址是否相等
        Integer c1 = 12;
        int c2 = 12;
        System.out.println(c1 == c2);
    }
}
